<?php
	$aPseudos1 = pg_query($oSql, 'SELECT DISTINCT pseudo, edition FROM participation');
	$aPseudos2 = pg_query($oSql, 'SELECT DISTINCT pseudo, edition FROM participation');


	$aEditions = pg_query($oSql, 'SELECT edition FROM tournoi');

	if(isset($_POST["numero"])){
		list($pseudoj1, $editionj1) = split('#', $_POST["pseudoj1"]);
		list($pseudoj2, $editionj2) = split('#', $_POST["pseudoj2"]);

		pg_query($oSql, "	INSERT INTO match(dateheure,duree,pointegerj1,pointegerj2,j1pseudo,j1edition,j2pseudo,j2edition,numero)
							VALUES(	'" . $_POST["dateheure"] . "'," . $_POST["duree"] . "," . $_POST["pointegerj1"] . "," . $_POST["pointegerj2"] . ",
									'" . $pseudoj1 . "','" . $editionj1 . "','" . $pseudoj2 . "','" . $editionj2 . "'," . $_POST["numero"] . ")
				");

		pg_query($oSql, "	UPDATE participation SET " . $_POST["round"] . " = " . $_POST["numero"] . " WHERE pseudo = '" . $pseudoj1 . "' AND edition = '" . $editionj1 . "'");
		pg_query($oSql, "	UPDATE participation SET " . $_POST["round"] . " = " . $_POST["numero"] . " WHERE pseudo = '" . $pseudoj2 . "' AND edition = '" . $editionj2 . "'");
	}
?>